package tsb.trinhnx;

import java.util.Comparator;

public class TreeNode<T> implements Comparator<T> {
	// Contains the value
	private T nodeValue;
	// First children
	private TreeNode<T> firstChild;
	// Point to next same node
	private TreeNode<T> nextSibling;
	// Point to the parent
	private TreeNode<T> parent;

	public TreeNode() {
		firstChild = nextSibling = parent = null;
		nodeValue = null;
	}

	public TreeNode(T data) {
		this();
		this.nodeValue = data;
	}

	public TreeNode<T> getFirstChild() {
		return firstChild;
	}

	public void setFirstChild(TreeNode<T> firstChild) {
		this.firstChild = firstChild;
	}

	public TreeNode<T> getNextSibling() {
		return nextSibling;
	}

	public void setNextSibling(TreeNode<T> nextSibling) {
		this.nextSibling = nextSibling;
	}

	public TreeNode<T> getParent() {
		return parent;
	}

	public void setParent(TreeNode<T> parent) {
		this.parent = parent;
	}

	public T getNodeValue() {
		return nodeValue;
	}

	public void setNodeValue(T nodeValue) {
		this.nodeValue = nodeValue;
	}

	@Override
	public int compare(T o1, T o2) {
		// TODO: implement the T hash code :3
		return o1.hashCode() - o2.hashCode();
	}

	@Override
	public String toString() {
		// TODO Auto-generated method stub
		return nodeValue.toString();
	}
}
